package com.site.dao.impl.dining;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.site.dao.dining.DishesDao;
import com.site.dto.dining.DishesBizBean;
import com.site.model.dining.DishesInfo;
import com.site.util.StringUtils;
import com.site.util.base.dao.BaseDaoImpl;
import com.site.util.extremetable.QueryPage;

/**
 * 普通菜单Dao
 * @author win7
 *
 */
@Repository
public class DishesDaoImpl extends BaseDaoImpl implements DishesDao {

	@Override
	public List<DishesInfo> getDishes(QueryPage queryPage, DishesBizBean dishesBizBean) {
		String hql = "from DishesInfo where 1 = 1";
		Map<String, Object> map = new HashMap<String, Object>();
		if(null != dishesBizBean){
			if(dishesBizBean.getRmid() != null){
				hql+=" and rmid = :rmid";
				map.put("rmid", dishesBizBean.getRmid());
			}
			if(!StringUtils.isEmpty(dishesBizBean.getTitle())){
				hql+=" and title like :title";
				map.put("title", "%"+dishesBizBean.getTitle()+"%");
			}
		}
		if(queryPage == null){
			return super.findByHQL(hql, map);
		} else {
			return super.findByHQL(queryPage, hql, map, false);
		}
	}
}
